custom function to array prototype in javascript